package com.ruoyi.business.controller;

import com.ruoyi.business.domain.koc.TbKocTask;
import com.ruoyi.business.domain.vo.TbKocTaskAllVO;
import com.ruoyi.business.service.koc.ITbKocTaskService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;


@Validated
@Api(value = "koc任务列表", tags = {"koc任务列表"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/koc/task")
public class TbKocTaskController extends BaseController {


    @Resource
    private ITbKocTaskService tbKocTaskService;


    @ApiOperation("查询全部koc任务列表")
    @GetMapping("/all")
    public R<List<TbKocTaskAllVO>> all() {
        return R.ok((tbKocTaskService.queryAll()));
    }

    @ApiOperation("koc任务列表")
    @GetMapping("/list")
    public TableDataInfo<TbKocTask> list(@ApiParam(name = "name", required = false) @RequestParam(required = false) String name, PageQuery pageQuery) {
        return tbKocTaskService.selectPageList(name, pageQuery);
    }


    @ApiOperation("获取koc任务详情")
    @GetMapping("/{id}")
    public R<TbKocTask> getInfo(@ApiParam("主键")
                                @NotNull(message = "主键不能为空") @PathVariable("id") Long id) {
        return R.ok(tbKocTaskService.queryById(id));
    }


    @ApiOperation("根据taskTypeId查询task列表")
    @GetMapping("/tasks-by-type-id")
    public R<List<TbKocTask>> getByTaskTypeId(@ApiParam("taskTypeId") @RequestParam(required = true) long taskTypeId) {
        return R.ok(tbKocTaskService.queryByTaskId(taskTypeId));
    }

}
